<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /**
      * Definition for singly-linked list.
      * function ListNode(val, next) {
      *     this.val = (val===undefined ? 0 : val)
      *     this.next = (next===undefined ? null : next)
      * }
      */
      /**
      * @param {ListNode} head
      * @return {ListNode}
      */
      var deleteDuplicates = function(head) {
        console.log(head)
          let before = head[0]
          let res = [before]
          for(let i=1; i<head.length; i++){
              if(head[i] != before){
                  res.push(head[i])
              }
              before = head[i] 
              
          }
        
          return res
      };
      console.log(deleteDuplicates([1,1,2])) 
      
      var deleteDuplicates = function(head) {
    if (!head) {
        return head;
    }

    let cur = head;
    while (cur.next) {
        if (cur.val === cur.next.val) {
            cur.next = cur.next.next;
        } else {
            cur = cur.next;
        }
    }
    return head;
};

  </script>
</body>
</html>
